#@layout() #define main()
<link rel="stylesheet" href="_common/ztree/zTreeStyle.css" type="text/css">
<script type="text/javascript" src="_common/ztree/jquery.ztree.core.min.js"></script>
<script type="text/javascript" src="_common/ztree/jquery.ztree.excheck.min.js"></script>

<div style="padding: 10px 30px 30px 30px;">
	<ul id="treeRight" class="ztree"></ul>
</div>
<form class="layui-form" id="right_form">
	<input type="hidden" name="rights" id="rights">
	<input type="hidden" name="ID" value="#(id)">
	<input type="hidden" name="bAdd" value="#(bAdd)">
</form>
<script>
$(function(){
	layui.use('layer');
	
	/*权限*/
	var setting = {
		check: {
			enable: true,
			chkDisabledInherit: true
		},
		data: {
			simpleData: {
				enable: true
			}
		}
	};

	var zNodes=#(zNode);
	$.fn.zTree.init($("#treeRight"), setting, zNodes);
});

function saveRight(){
	var zTree = $.fn.zTree.getZTreeObj("treeRight");
	var nodes=zTree.getCheckedNodes(true);
	var right="";
	for(var i=0;i<nodes.length;i++){
	  	//alert(nodes[i].name);
		right+=(nodes[i].id+",");
	}
	$("#rights").val(right);
	$.post('xpDepartment/right', $("#right_form").serialize(), function(res) {
		if (res.result == 1) {
			layer.msg(res.msg, {
				icon : 1,
				time : 1000
			}, function() {
				parent.parent.layer.closeAll('iframe');
				parent.parent.reloadList();
			});
		} else {
			layer.msg(res.msg, {
				icon : 5
			});
		}
	});
}
</script>
#end

